package com.jchy.graph;

public class Vertex implements Comparable<Object> {

	protected long id;

    protected String label;

	public Vertex()
	{
		id = 0L;
        label = new String("");
	}
	
	public Vertex(long inId)
	{
		id = inId;
	}
	
	public long getId() {
		return id;
	}
	
	public String getLabel() {
        String result;
        if(label == null)
            result = new String("");
        else 
            result = new String(label);
        return result;
    }

    public int hashCode() {
		int retval;
		Long aLong = new Long(id);
		retval = aLong.hashCode();
		return retval;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public void setLabel(String label) {
        if(label == null)
            this.label = new String("");
        else
            this.label = new String(label);
    }

    public boolean equals(Vertex inVertex)
	{
		return inVertex.getId() == id;
	}
	
    public boolean equals(Object inObject)
	{
		return ((Vertex)inObject).getId() == id;
	}
	
	public String toString()
	{
		return String.valueOf(id);
	}
	
	public int compareTo(Vertex inVertex)
	{
		int result;
		if(inVertex.getId() > id)
			result = 1;
		else if(inVertex.getId() < id)
			result = -1;
		else
			result = 0;
		
		return result;
	}
	
	public int compareTo(Object a)
	{
		int result;
		Vertex vert;
		
		vert = (Vertex)a;
		if(vert.getId() > id)
			result = 1;
		else if(vert.getId() < id)
			result = -1;
		else
			result = 0;
		
		return result;
	}
	
	public final int compare ( Object a, Object b )
    {
		return( (Vertex)a ).compareTo( (Vertex)b );
    } // end compare
		
}
